/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simhya.modelchecking;

import java.util.Arrays;


/**
 *
 * @author Luca
 */
public class SMCestimateTrajectory implements SMCcontroller, SMCoutput {
    double[] estimate;
    double[] upperConfidenceBound;
    double[] lowerConfidenceBound;
    
    long total;
    long[] good;
    
    double error;
    double confidence;
    int points;
    
    int samplesNeeded;
    String formula;
    
    boolean stop = false;

    public SMCestimateTrajectory(int points) {
        error = 1e-4;
        confidence = 0.95;
        this.points = points;
        this.samplesNeeded = this.computeNeededSamples();
        init();
    }

    public SMCestimateTrajectory(int points, double error, double confidence) {
        this.error = error;
        this.confidence = confidence;
        this.points = points;
        this.samplesNeeded = this.computeNeededSamples();
        init();
    }
    
    public SMCestimateTrajectory(int points, int samples, double confidence) {
        this.confidence = confidence;
        this.points = points;
        this.samplesNeeded = samples;
        init();
    }

    private void init() {
        estimate = new double[points];
        this.upperConfidenceBound = new double[points];
        this.lowerConfidenceBound = new double[points];
        this.good = new long[points];
        Arrays.fill(good, 0);
    }
    
    //TO BE IMPLEMENTED
    private int computeNeededSamples() {
        return 1000;
    }

    public void setFormula(String formula) {
        this.formula = formula;
    }
    
    public void addPoint(boolean[] truth) {
        if (truth.length != points)
            throw new RuntimeException("Number of points mismatch!");
        total++;
        for (int i=0;i<points;i++)
            if (truth[i])
                good[i]++;
        this.checkStopCondition();
    }
    
    
    private void checkStopCondition() {
        
    }
    
    
    public boolean stop() {
        return stop;
    }
    
    
    public void finalize() {
        
    }
    
    
    
    //TO DO: plot methods, save methods, ... 
    
    
}
